<div class="page-bar">
    <ul class="page-breadcrumb">
        <li>
            <a href="#">WMS</a>
            <i class="fa fa-circle"></i>
        </li>
        <li>
            <a href="#">Task</a>
            <i class="fa fa-circle"></i>
        </li>
        <li>
            <a href="#">pack</a>
            <i class="fa fa-circle"></i>
        </li>
        <li>
            <a href="#">Parcel pack Task List</a>
        </li>
    </ul>
</div>
<div class="container-fluid" style="margin: 15px;">
    <div class="portlet light bordered">
        <div class="portlet-title">
            <div class="caption">
                <span class="caption-subject bold">Parcel Pack Task List</span>
            </div>
        </div>
        <div class="portlet-body form form-horizontal">
            <form>
                <div class="row form-group">
                    <div class="col-md-3">
                        <label>Task ID</label>
                        <lt-tags-input ng-model="search.taskIds" placeholder="Enter Task ID" fill="TASK-" ng-keyup="keyUpSearch($event)"></lt-tags-input>
                    </div>
                    <div class="col-md-3">
                        <label>Assignee</label>
                        <user-auto-complete name="assignee" allow-clear="true"
                                            ng-model="search.assigneeUserId"></user-auto-complete>
                    </div>
                    <div class="col-md-3">
                        <label>Status</label>
                        <task-status-auto-complete  allow-clear="true" ng-model="search.status"></task-status-auto-complete>
                    </div>
                    <div class="col-md-3">
                        <label>SLP ID:</label>
                        <input class="form-control" name="SLP ID" placeholder="Enter SLP ID" ng-model="search.slpId" ng-keyup="keyUpSearch($event)"/>
                    </div>
                </div>
                <div class="row form-group">
                    <div class="col-md-6">
                        <label>Tracking Nos:</label>
                        <lt-tags-input ng-model="search.trackingNos" placeholder="Enter Tracking NO" ng-keyup="keyUpSearch($event)"></lt-tags-input>
                    </div>
                </div>
                <div class="row form-group">
                    <div class="col-md-3">
                        <label>Start Time</label>
                        <lt-date-time placeholder="From" date-format="yyyy-mm-dd hh:ii" minute-step="60"
                                      value="search.startTimeFrom"></lt-date-time>
                    </div>
                    <div class="col-md-3" style="padding-top: 25px;">
                        <lt-date-time placeholder="To" date-format="yyyy-mm-dd hh:ii" minute-step="60"
                                      value="search.startTimeTo"></lt-date-time>
                    </div>
                    <div class="col-md-3">
                        <label>End Time</label>
                        <lt-date-time placeholder="From" date-format="yyyy-mm-dd hh:ii" minute-step="60"
                                      value="search.endTimeFrom"></lt-date-time>
                    </div>
                    <div class="col-md-3" style="padding-top: 25px;">
                        <lt-date-time placeholder="To" date-format="yyyy-mm-dd hh:ii" minute-step="60"
                                      value="search.endTimeTo"></lt-date-time>
                    </div>
                </div>
                <div class="form-actions right">
                    <waitting-btn type="submit" btn-class="btn blue" ng-click="searchTasks()"
                                  value="'search'" is-loading="searching"></waitting-btn>
                </div>
            </form>
            <div ng-show="searching" class="text-center">
                <img src="assets/img/loading-spinner-grey.gif">
                <span>&nbsp;LOADING...</span>
            </div>
            <div class="table-scrollable">
                <table class="table table-striped table-bordered table-hover" ng-show="!searching">
                    <thead>
                    <tr>
                        <th>Task ID</th>
                        <th>Assignee</th>
                        <th>Status</th>
                        <th>Priority</th>
                        <th>Location</th>
                        <th>LP</th>
                        <th width="15%">Tracking NO</th>
                        <th>package Type</th>
                        <th>Start Time</th>
                        <th>End Time</th>
                        <th>Description</th>
                        <th permission-check="{{'task::parcelPackTask_write'}}">Actions</th>
                    </tr>

                    </thead>
                    <tbody>
                    <tr ng-repeat="task in tasks">
                        <td><a ng-href="{{'#/wms/task/pack-task/parcel/' + task.id + '/view'}}" target="_blank">{{task.id}}</a></td>
                        <td>{{ task.assignee.firstName + ' ' + task.assignee.lastName}}</td>
                        <td>{{ task.status }}</td>
                        <td>{{ task.priority }}</td>
                        <td>{{ task.steps[0].locationName }}</td>
                        <td > <span ng-repeat="lp in task.lpIds" style="display: block">{{lp}}</span></td>
                        <td>
                            <span ng-repeat="trackingNo in task.trackingNos" style="display: block">{{trackingNo}} </span>
                        </td>
                        <td>{{ task.steps[0].packageType }}</td>
                        <td>{{ task.startTime | amDateFormat:'YYYY-MM-DD HH:mm'}}</td>
                        <td>{{ task.endTime | amDateFormat:'YYYY-MM-DD HH:mm' }}</td>
                        <td>{{ task.description }}</td>
                        <td permission-check="{{'task::parcelPackTask_write'}}">
                            <a ng-click="deleteTask(task.id)"
                               ng-show="task.status == 'New'" title="Delete">Delete</a>
                        </td>
                    </tr>
                    </tbody>
                </table>
            </div>
            <pager total-count="paging.totalCount" current-page ="paging.pageNo" page-size="pageObj.pageSize"  load-content="loadContent(currentPage)"></pager>
        </div>
    </div>
</div>
